package com.ocom.accesservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.accesservice.dao.IDaoCompanyListInfo;
import com.ocom.accesservice.service.CompanyListInfoService;
import com.ocom.common.entity.master.EntityCompanyList;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.utils.StringUtils;
import com.ocom.mysql.aspect.DataSourceAspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyListInfoServiceImpl extends ServiceImpl<IDaoCompanyListInfo, EntityCompanyList> implements CompanyListInfoService {


    @Autowired
    private IDaoCompanyListInfo companyListInfo;
    /**
     * 查找comId集合
     *
     * @return*/
    @DataSourceAspect(type = DataSourceEnum.MAIN_DB)
    @Override
    public List<EntityCompanyList> FindMachComId(Integer agentId) {
        QueryWrapper<EntityCompanyList> query = Wrappers.query();
        if (StringUtils.isNotNull(agentId)){
            query.eq("agent_id",agentId);
        }
        return companyListInfo.selectList(query);
    }
}
